﻿package net.wangit.framework.action;

import net.wangit.framework.cache.Cache;
import net.wangit.framework.util.CacheUtil;
/**
 * ActionMapping缓存类
 * @author watson
 *
 */
public class ActionMappingCache {

	public ActionMappingCache() {
	}

	public static ActionMapping get(String domain, String unitId,
			String elementId) {
		return (ActionMapping) getCache(domain).get(getKey(unitId, elementId));
	}

	public static void put(String domain, String unitId, String elementId,
			ActionMapping mapping) {
		getCache(domain).put(getKey(unitId, elementId), mapping);
	}

	public static void clear(String domain, String unitId, String elementId) {
		getCache(domain).clear(getKey(unitId, elementId));
	}

	public static void clearAll(String domain) {
		getCache(domain).clearAll();
	}

	private static String getKey(String unitId, String elementId) {
		return (new StringBuilder(String.valueOf(unitId))).append(",").append(
				elementId).toString();
	}

	private static Cache getCache(String domain) {
		return CacheUtil.getActionMappingCache(domain);
	}
}
